<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<c:set var="currentMenu" value="${empty boardType ? board.boardType : boardType }" />
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="author" content="" />
<title>JK Holdings</title>
<script src="/js/jquery-1.6.4.js"></script>
<script type="text/javascript">

var validationInfo = {
	validationInfoList : [
		{ inputId : 'name', 		errorMessage : '등록자를 입력해주세요' 		},
		{ inputId : 'password', 	errorMessage : '비밀번호를 입력해주세요' 	},
		{ inputId : 'title', 		errorMessage : '제목을 입력해주세요' 		},
		{ inputId : 'contents', 	errorMessage : '내용을 입력해주세요' 		}
	]
};

$(document).ready(function() {
	
	$('#qnaBoardSaveButton').click(function(){
		
		var submitCheckStatus = true;
		$.each(validationInfo.validationInfoList, function(key, value) {
			var $tempInputObj = $('#'+value.inputId);
			
			if($tempInputObj.val().length < 1 ){
				alert(value.errorMessage);
				$tempInputObj.focus();
				submitCheckStatus = false;
				return false;
			}
			
		});
		
		if( submitCheckStatus == true ){
			$('#boardForm').submit();
		}
	});
	
	$('#goQnaListButton').click(function(){
		location.href = "/board/list.do?boardType=${currentMenu}";
	});

});

</script>
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" />
</head>

<body id="top">
	<!-- 공통 헤더 시작 -->
	<%@ include file="/WEB-INF/head.jsp"%>
	<!-- 공통 헤더 끝 -->

	<!-- 메인 네비게이션 시작  -->
	<%@ include file="/WEB-INF/navigation.jsp"%>
	<!-- 메인 네비게이션 끝  -->

	<div id="content-wrapper">
		<div class="center-wrapper">

			<div class="content" id="content-two-columns">

				<div id="main-wrapper">
					<div id="main">
							<div class="post">
								<div class="post-title">
									<h1>
										<c:choose>
											<c:when test='${board.boardType == "qna" || board.boardType == "QNA"}'>
							            		질문/답변 수정
							        		</c:when>
							        		<c:otherwise>
							           			공지 사항 수정
							        		</c:otherwise>
										</c:choose> 
									</h1>
								</div>
								<div class="post-body">
									<form id="boardForm" action="/board/form/update.do" method="post">
										<table class="data-table">
											<tr>
												<th>작성자</th>
												<td><input type="text" name="boardWriter" id="name" value="${board.boardWriter}" /></td>
												<th>비밀번호</th>
												<td><input type="password" name="boardPassWord" id="password" /></td>
											</tr>
											
											<tr>
												<th>제목</th>
												<td colspan="3"><input type="text" name="boardTitle" id="title" value="${board.boardTitle}"/></td>
											</tr>
											<tr>
												<td colspan="4">
													<textarea id="contents" name="boardContent">${board.boardContent}</textarea>												
												</td>
											</tr>
										</table>
										<input name="boardType" type="hidden" value="${empty boardType ? board.boardType : boardType }"/>
										<input name="boardId" type="hidden" value="${board.boardId}"/>
									</form>
								</div>
							</div>
						<button id="qnaBoardSaveButton" type="button" class="save" title="수정">
							<span>수정</span>
						</button>
						<button id="goQnaListButton" type="button" class="list" title="목록">
							<span>목록</span>
						</button>
					</div>
				</div>

				<div id="sidebar-wrapper">
					<div id="sidebar">

						<!-- 카테고리 box 시작 -->
						<%@ include file="/WEB-INF/category.jsp"%>
						<!-- 카테고리 box 끝 -->

						<div class="box nobborder">

							<div class="box-title">About</div>

							<div class="box-content">
								<p>뭔가 About 설명이 들어가야할 영역</p>
							</div>

						</div>

					</div>
				</div>

				<div class="clearer">&nbsp;</div>

			</div>

		</div>
	</div>

	<!-- bottom 시작 -->
	<%@ include file="/WEB-INF/bottom.jsp"%>
	<!-- bottom 끝 -->

</body>
</html>